/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aal.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.annotation.Generated;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author quy
 */
@Entity
@Table(name = "Warehouse")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Warehouse.findByName", query = "SELECT w FROM Warehouse w WHERE w.warehouseName = :warehouseName order by w.warehouseID"),
    @NamedQuery(name = "Warehouse.findAll", query = "SELECT w FROM Warehouse w"),
    @NamedQuery(name = "Warehouse.findByWarehouseID", query = "SELECT w FROM Warehouse w WHERE w.warehouseID = :warehouseID"),
    @NamedQuery(name = "Warehouse.findByWarehouseName", query = "SELECT w FROM Warehouse w WHERE w.warehouseName  LIKE :warehouseName order by w.warehouseID"),
    @NamedQuery(name = "Warehouse.findByWarehouseLocation", query = "SELECT w FROM Warehouse w WHERE w.warehouseLocation = :warehouseLocation"),
    @NamedQuery(name = "Warehouse.findByWarehouseDescription", query = "SELECT w FROM Warehouse w WHERE w.warehouseDescription = :warehouseDescription")})
public class Warehouse implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "WarehouseID")
    private Integer warehouseID;
    @Size(max = 255)
    @Column(name = "WarehouseName")
    private String warehouseName;
    @Size(max = 255)
    @Column(name = "WarehouseLocation")
    private String warehouseLocation;
    @Size(max = 2000)
    @Column(name = "WarehouseDescription")
    private String warehouseDescription;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "warehouse")
    private Collection<ProductWarehouse> productWarehouseCollection;
    @OneToMany(mappedBy = "warehouseID")
    private Collection<WarehouseIO> warehouseIOCollection;

    public Warehouse() {
    }

    public Warehouse(Integer warehouseID) {
        this.warehouseID = warehouseID;
    }

    public Integer getWarehouseID() {
        return warehouseID;
    }

    public void setWarehouseID(Integer warehouseID) {
        this.warehouseID = warehouseID;
    }

    public String getWarehouseName() {
        return warehouseName;
    }

    public void setWarehouseName(String warehouseName) {
        this.warehouseName = warehouseName;
    }

    public String getWarehouseLocation() {
        return warehouseLocation;
    }

    public void setWarehouseLocation(String warehouseLocation) {
        this.warehouseLocation = warehouseLocation;
    }

    public String getWarehouseDescription() {
        return warehouseDescription;
    }

    public void setWarehouseDescription(String warehouseDescription) {
        this.warehouseDescription = warehouseDescription;
    }

    @XmlTransient
    public Collection<ProductWarehouse> getProductWarehouseCollection() {
        return productWarehouseCollection;
    }

    public void setProductWarehouseCollection(Collection<ProductWarehouse> productWarehouseCollection) {
        this.productWarehouseCollection = productWarehouseCollection;
    }

    @XmlTransient
    public Collection<WarehouseIO> getWarehouseIOCollection() {
        return warehouseIOCollection;
    }

    public void setWarehouseIOCollection(Collection<WarehouseIO> warehouseIOCollection) {
        this.warehouseIOCollection = warehouseIOCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (warehouseID != null ? warehouseID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Warehouse)) {
            return false;
        }
        Warehouse other = (Warehouse) object;
        if ((this.warehouseID == null && other.warehouseID != null) || (this.warehouseID != null && !this.warehouseID.equals(other.warehouseID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aal.entity.Warehouse[ warehouseID=" + warehouseID + " ]";
    }
    
}
